<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
    <meta content="telephone=no,email=no" name="format-detection">
    <!--禁止自动识别电话号码和邮箱-->
    <meta content="yes" name="apple-mobile-web-app-capable">
    <!--苹果手机：会删除默认的工具栏和菜单栏，网站开启对web app程序的支持-->
    <meta name="apple-mobile-web-app-status-bar-style" content="default"/>
    <!--苹果手机：在web app应用下状态条（屏幕顶部条）的颜色,默认值为default（白色），可以定为black（黑色）和black-translucent（灰色半透明）。-->
    <meta name="apple-touch-fullscreen" content="yes"/>
    <!--苹果手机：如果把一个web app添加到了主屏幕中，那么从主屏幕中打开这个web app则全屏显示-->
    <link rel="stylesheet" type="text/css" href="css/applicationCash.css">
    <link rel="stylesheet" type="text/css" href="css/mescroll.min.css">
    <script src="js/jquery-3.3.1.js"></script>
    <script src="js/layer.js"></script>
    <script src="js/utils.js"></script>
    <title></title>
</head>
<body>
<div id="vueData">
    <header>
        <div class="title_header dis_flex">
            <div class="dis_flex" @click="goBack">
                <img src="img/return_2.png">
            </div>
            <div>
                <span>提现申请审核</span>
            </div>
            <div></div>
        </div>
    </header>
    <div class="body">
        <div class="body_dt">
            <ul>
                <li class="actives">待审核</li>
                <li>已审核</li>
            </ul>
        </div>
        <div id="mescroll" class="mescroll">
            <div v-if="currentTab==0" class="body_dd">
                <div class="dis_flex" v-if="ds.length==0">没有记录</div>
                <div v-else class="dis_flex" v-for="(item,index) in ds">
                    <div class="input_information">
                        <span>申请人姓名：</span>
                        <span>{{item.userName}}</span>
                    </div>
                    <div v-if="item.bankName" class="input_information">
                        <span>银行：</span>
                        <span>{{item.openingBank}}</span>
                    </div>
                    <div v-if="item.cardNumber" class="input_information">
                        <span>卡号：</span>
                        <span>{{item.cardNumber}}</span>
                    </div>
                    <div class="input_information">
                        <span>提款金额：</span>
                        <span>{{item.amountCash}}</span>
                    </div>
                    <div class="putForward">
                        <span @click="auditPass(index)">审核通过</span>
                    </div>
                    <div class="putForward">
                        <span @click="auditRefused(index)">拒绝通过</span>
                    </div>
                </div>
            </div>
            <div v-else-if="currentTab==1" class="body_dd">
                <div class="dis_flex" v-if="ds.length==0">没有记录</div>
                <div v-else class="dis_flex" v-for="item in ds">
                    <div class="input_information">
                        <span>申请人姓名：</span>
                        <span>{{item.userName}}</span>
                    </div>
                    <div v-if="item.bankName" class="input_information">
                        <span>银行：</span>
                        <span>{{item.openingBank}}</span>
                    </div>
                    <div v-if="item.cardNumber" class="input_information">
                        <span>卡号：</span>
                        <span>{{item.cardNumber}}</span>
                    </div>
                    <div class="input_information">
                        <span>提款金额：</span>
                        <span>{{item.amountCash}}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="js/mescroll.min.js"></script>
<script>
    let localStore = JSON.parse(localStorage.localStore), pageIndex = 1, pageCount = 20, totalPage = 0;
    let vm = new Vue({
        el: '#vueData',
        data: {
            currentTab: 0,
            ds: [],
            mescroll: null
        }, mounted: function () {
            let that = this;
            $('.body_dt>ul>li').click(function () {
                let selectIndex = $(event.currentTarget).index();
                if (vm.currentTab === selectIndex) {
                    return;
                }
                vm.currentTab = selectIndex;
                $(event.currentTarget).addClass('actives').siblings('li').removeClass('actives');
                emptyData();
                loadToDoPro();
            });

            that.mescroll = new MeScroll("mescroll", {
                up: {
                    callback: that.upCallback,
                    auto: false,
                    noMoreSize: 20
                }, down: {
                    callback: that.downCallback,
                    auto: false
                }
            });
        }, methods: {
            upCallback() {
                if (totalPage > pageIndex) {
                    loadToDoPro(function () {
                        vm.mescroll.endByPage(pageCount, totalPage);
                    }, function () {
                        vm.mescroll.endErr();
                    });
                } else {
                    vm.mescroll.endByPage(pageCount, totalPage);
                }
            }, downCallback() {
                emptyData();
                loadToDoPro(function () {
                    vm.mescroll.endByPage(pageCount, totalPage);
                }, function () {
                    vm.mescroll.endErr();
                });
            },
            goBack() {
                history.back();
            }, auditPass(index) {
                let id = vm.ds[index].id;
                $.ajax({
                    url: '/shanduonewretail/jpresent/presentsucceed',
                    data: {token: localStore.token, presentId: id},
                    success: function (res) {
                        if (res.success) {
                            let ary = vm.ds;
                            ary.splice(index, 1);
                            vm.ds = ary;
                            toast(res.result);
                        } else {
                            toast(res.errCodeDes)
                        }
                    }
                });
            }, auditRefused(index) {
                let id = vm.ds[index].id;
                $.ajax({
                    url: '/shanduonewretail/jpresent/rejectsucceed',
                    data: {token: localStore.token, presentId: id},
                    success: function (res) {
                        if (res.success) {
                            let ary = vm.ds;
                            ary.splice(index, 1);
                            vm.ds = ary;
                            toast(res.result);
                        } else {
                            toast(res.errCodeDes)
                        }
                    }
                });
            }
        }
    });
    $(function () {
        loadToDoPro();
    });

    function emptyData() {
        let ary = vm.ds;
        ary.splice(0, ary.length);
        vm.ds = ary;
        totalPage = 0;
        pageIndex = 1;
    }

    function loadToDoPro(cbOk, cbErr) {
        if (localStore.jurisdiction == 1) {
            $.ajax({
                url: '/shanduonewretail/jpresent/presentList',
                data: {
                    token: localStore.token,
                    state: vm.currentTab + 1,// 订单状态:1:申请提现2:同意提现;3.拒绝提现;
                    page: pageIndex,
                    pageSize: pageCount
                }, success: function (res) {
                    if (res.success) {
                        vm.ds = vm.ds.concat(res.data);
                        totalPage = res.totalPage;
                    }
                    cbOk && cbOk();
                }, error: function () {
                    cbErr && cbErr();
                }
            });
        }
    }

    function emptyData() {
        let ary = vm.ds;
        ary.splice(0, ary.length);
        vm.ds = ary;
        totalPage = 0;
        pageIndex = 1;
    }
</script>

</body>
</html>